package com.ziroom.zifamily.zfms.service.conser;

import com.github.pagehelper.PageInfo;
import com.ziroom.zifamily.zfms.pojo.vo.CensorContentVO;
import com.ziroom.zifamily.zfms.mapper.base.LoginLogEntityMapper;
import com.ziroom.zifamily.zfms.mapper.censor.CensorContentEntityMapper;
import com.ziroom.zifamily.zfms.mapper.censor.entity.CensorContentEntity;
import com.ziroom.zifamily.zfms.pojo.bo.CensorContentBO;
import com.ziroom.zifamily.zfms.service.BaseService;
import com.ziroom.zifamily.zfms.common.util.CommonUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author xinggh
 * @version 1.0
 * @date Created in 2018年12月03日 11:08
 * @since 1.0
 */
@Service

public class CensorContentService extends BaseService{

    @Autowired
    private LoginLogEntityMapper loginLogEntityMapper;

    @Autowired
    private CensorContentEntityMapper censorContentEntityMapper;

    /***
     * 分页查询审核内容
     * @param query
     * @return
     */

    public PageInfo<CensorContentVO> findCensorContentByQuery(@Param("request")CensorContentBO query){
        List<CensorContentVO> censorContentEntityDTOList = new ArrayList<CensorContentVO>();

        List<CensorContentEntity> censorContentEntityList= censorContentEntityMapper.findByQuery(query);
        PageInfo<CensorContentVO> pageInfo = new PageInfo(censorContentEntityList);

        for(CensorContentEntity censorContentEntity:censorContentEntityList){
            CensorContentVO censorContentEntityDTO = new CensorContentVO();

            //脱敏处理
            String mobile = CommonUtils.mobileEncrypt(censorContentEntity.getSenderPhone());
            //copy
            BeanUtils.copyProperties(censorContentEntity,censorContentEntityDTO);
            censorContentEntityDTO.setSenderPhoneEcrypted(mobile);
            censorContentEntityDTOList.add(censorContentEntityDTO);
        }
        pageInfo.setList(censorContentEntityDTOList);

        return pageInfo;

    }

}
